package com.superteam.zzl.activity;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.Window;

import com.superteam.zzl.activity.databinding.ActivityAuthorBinding;
import com.superteam.zzl.activity.implement.IAuthorActivityEvent;
import com.superteam.zzl.activity.implement.IOneselfActivityView;
import com.superteam.zzl.model.DynamicFragment.bean.Dynamic;
import com.superteam.zzl.viewmodel.DynamicFragment.ContentInfoPresenter;
import com.superteam.zzl.widget.MyImageView;

import java.io.Serializable;
import java.util.ArrayList;

public class AuthorActivity extends AppCompatActivity implements IOneselfActivityView, View.OnClickListener, IAuthorActivityEvent{


    private ContentInfoPresenter presenter;
    private ActivityAuthorBinding db;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        db = DataBindingUtil.setContentView(this, R.layout.activity_author);
        Dynamic.DataBean.TrendsListBean data = getData();
        db.setTrends(data);
//        db.layout.setTrends(data);

         presenter = new ContentInfoPresenter(this, this, db);
        presenter.setData(getData());
        presenter.init();
        presenter.initView();
        setSupportActionBar(db.tl);
        db.tl.setNavigationOnClickListener(this);
    }

    @Override
    public void show() {

    }

    @Override
    public void onClick(View v) {
        finish();
    }

    public Dynamic.DataBean.TrendsListBean getData() {
        Serializable data = getIntent().getSerializableExtra("data");
        return ((Dynamic.DataBean.TrendsListBean) data);
    }

    @Override
    public void myClick(View view) {
        switch (view.getId()) {
            case R.id.iv:
                Intent intent = new Intent(this, ImageActivity.class).putExtra("data1", ((ArrayList) presenter.getData().image_list)).putExtra("pos", ((MyImageView) view).getPosition());
                startActivity(intent);
                break;
            case R.id.iv1:
                Log.e("AuthorActivity", "myClick: ");
                break;

            default:
                break;
        }
        
    }
}
